//
// Created by madison on 2022/4/15.
//

#include <iostream>

using namespace std;

int main() {

    void fun1();
    fun1();

    void fun2();
    fun2();
    return 0;
}

void fun1() {
    int n1, n2;
    cout << "输入两个整数: ";
    cin >> n1 >> n2;
    while (n1 != n2) {
        if (n1 > n2) {
            n1 -= n2;
        } else {
            n2 -= n1;
        }
    }

    cout << "HCF = " << n1;
    cout << endl;
}

void fun2() {
    int n1, n2, hcf;
    cout << "输入两个整数: ";
    cin >> n1 >> n2;

    // 如果 n2 大于 n1 交换两个变量
    if (n2 > n1) {
        int temp = n2;
        n2 = n1;
        n1 = temp;
    }

    for (int i = 1; i <= n2; ++i) {
        if (n1 % i == 0 && n2 % i == 0) {
            hcf = i;
        }
    }

    cout << "HCF = " << hcf;
    cout << endl;
}